package com.System.LearnSystem;

import java.sql.Connection;
import java.sql.DriverManager;


public class sqlConnection {
	//数据库连接相关配置
	public static Connection getConnection()
    {
    	String username = "root";//登录本地sql数据库的用户信息
    	String password = "1234";
    	String url = "jdbc:mysql://127.0.0.1:3306/user";
    	try{
    		Class.forName("com.mysql.cj.jdbc.Driver");
    		Connection conn = DriverManager.getConnection(url, username, password);
    		
    		return 	conn;	
    	}catch(Exception e) {
    		throw new DatabaseException("获取数据库连接失败", e);
    	}
    }
	
}
class DatabaseException extends RuntimeException {

	public DatabaseException(String message) {
        super(message);
    }
    public DatabaseException(String message, Throwable cause) {
        super(message, cause);
    }
}